﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Presentation.Module.Scheduling.Interfaces.ViewModels;
using Presentation.Module.Scheduling.Interfaces.Views;
using Presentation.Module.Scheduling.ViewDto;
namespace Presentation.Module.Scheduling.Views
{
    /// <summary>
    /// Interaction logic for AddScheduleStudyView.xaml
    /// </summary>
    public partial class AddScheduleStudyView : UserControl,IAddScheduleStudyView
    {
        public AddScheduleStudyView(IAddScheduleStudyViewModel viewModel)
        {
            InitializeComponent();  

            this.ViewModel = viewModel;

            this.DataContext = this.ViewModel;
            
            this.ViewModel.View = this;

        }

        public IAddScheduleStudyViewModel ViewModel { get; private set; }

        public event Shell.Interfaces.ViewExit ViewExit;

        public void AddScheduleStudy()
        {
            this.ViewModel.CurrentScheduleStudy = new ScheduleStudy();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (this.ViewExit != null)
            {
                this.ViewExit.Invoke();
            }
        }

        private void UpdateControls(object sender, RoutedEventArgs e)
        {
            BindingExpression bindExp = ((ItemsControl)e.OriginalSource).GetBindingExpression(ItemsControl.ItemsSourceProperty);

            bindExp.UpdateSource();
            bindExp.UpdateTarget();
            this.InvalidateVisual();
        }
    }
}
